<?php
class EnticeActiveRecord extends CActiveRecord {
	private static $enticedb = null;

	protected static function getEnticeDbConnection()
	{
		if (self::$enticedb !== null)
			return self::$enticedb;
		else
		{
			self::$enticedb = Yii::app()->enticedb;
			if (self::$enticedb instanceof CDbConnection)
			{
				self::$enticedb->setActive(true);
				return self::$enticedb;
			}
			else
				throw new CDbException(Yii::t('yii','Active Record requires a "db" CDbConnection application component.'));
		}
	}
	
	public function getDbConnection()
	{
		return self::getEnticeDbConnection();
	}
}